package org.itsolutions.javaBackup.core;

import java.util.concurrent.atomic.AtomicBoolean;

import org.itsolutions.javaBackup.buffers.ByteBufferPool;
import org.itsolutions.javaBackup.exceptions.AException;
import org.itsolutions.javaBackup.logger.ELogLevel;
import org.itsolutions.javaBackup.logger.ILogger;
import org.itsolutions.javaBackup.logger.LoggerHelper;
import org.itsolutions.javaBackup.spi.EModule;
import org.itsolutions.javaBackup.spi.IModuleStartStopTask;

import com.google.inject.Inject;

/**
 * 
 * @author Tomas Fecko
 */
public final class CoreModuleStartStopTask implements IModuleStartStopTask {
	
	private static final ILogger		LOGGER = LoggerHelper.getLogger(CoreModuleStartStopTask.class);
	private static final AtomicBoolean	IS_STARTED = new AtomicBoolean(false);
	private final ByteBufferPool		mByteBufferPool;

	/**
	 * 
	 * @param pByteBufferPool buffer pool 
	 */
	@Inject public CoreModuleStartStopTask(ByteBufferPool pByteBufferPool) {
		mByteBufferPool = pByteBufferPool;
	}

	@Override
	public void start() throws AException {
		LOGGER.log(ELogLevel.DEBUG, "Starting Core module.");
		IS_STARTED.set(true);		
	}

	@Override
	public void stop() throws AException {
		LOGGER.log(ELogLevel.DEBUG, "Stopping Core module.");
		IS_STARTED.set(false);		
	}

	@Override
	public boolean isStarted() throws AException {
		return IS_STARTED.get();
	}

	@Override
	public EModule getModule() {
		return EModule.CORE;
	}
}





